home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / programer2 / aoflib / !ReadMe next >
Encoding:
Text File  |  1996-05-28  |  5.4 KB  |  187 lines

  1. AOFLib by William Gibbons of DWS
  2. ------
  3. AOFLib is a small BASIC library designed to let you save ARM code created
  4. with the BASIC assembler as AOF files. This allows them to be incorportated
  5. into programs written in C and other high-level languages.
  6.  
  7. See the Example directory for an example of linking BASIC assembler with a C
  8. program.
  9.  
  10.  
  11. Using AOFLib
  12. ------------
  13. AOFLib must be included in your BASIC source program via the LIBRARY command.
  14. If you don't want to do this every in every BASIC source you can use INSTALL
  15. to install the library.
  16.  
  17. You must call PROCInit before you use AOFLib; this initialises AOFLib
  18.  
  19. AOFLib provides ways of exporting labels from BASIC assembler and importing
  20. labels into assembler.
  21.  
  22. To export an address, you can use:
  23. FNexp("<Label name>") from your BASIC source.
  24.  
  25. You must assemble your code in this way:
  26. DIM code% &2000
  27. FOR pass%=4 TO 6 STEP 2
  28.  O%=code%:P%=0
  29.  [opt pass%
  30.   ...
  31.   FNexp("bloggs")
  32.   ...
  33.   your code here
  34.   ...
  35.  ]
  36. NEXT
  37.  
  38. ie, you must use pass% as your assembly counter. If you normally use
  39. something else, you can replace all instances of pass% in AOFLib with
  40. whatever you normally use using Edit's Search + Replace facility.
  41.  
  42. It isn't important that you use the name "code%", but it is important that
  43. pass% goes from 4 to 6, and that P% is set to 0. If it isn't, label
  44. address will be wrong.
  45.  
  46. That example will export the label name "bloggs" which can now be called as
  47. a procedure name from C source (see below).
  48.  
  49. You can export up to 64 label names in one BASIC assembler source file.
  50.  
  51. To import label names, there are two procedures: FNimp("<Label name>" and
  52. FNima("<Label name>").
  53.  
  54. Use FNimp() after B[L] and ADR
  55.  
  56. Eg:
  57.    ADR R0,str
  58.    BL FNimp("printf")
  59.  
  60. will pass the string pointed to by str to the function printf(), and:
  61.  
  62.    ADR R0,FNimp("printf")
  63.  
  64. will put the address of the printf() function in the register R0.
  65.  
  66.  
  67. Use FNima() when you want to put the address of a label in a word, eg
  68.  
  69.    EQUD FNima("printf")
  70.  
  71. will put the address of the function printf() into memory.
  72.  
  73.  
  74. Additionally, PROCexp("<Label name>",<Value>) is provided to let you export
  75. a label.
  76. Use:
  77. PROCexp("bloggs",a%)
  78. to export the (area-relative) value a% as a label with name "bloggs".
  79.  
  80.  
  81. Then use PROCSave to save your assembler procedure as an AOF file, eg:
  82. PROCSave("ADFS::4.$.AOFFile",code%,O%)
  83. will save the ARM code between the addresses code% and O% to the file
  84. ADFS::4.$.AOFFile and will save any labels you exported or imported too.
  85.  
  86. The AOF file can now be linked with C programs (see below)
  87.  
  88. Linking AOF files with C programs
  89. ---------------------------------
  90. AOF files to be linked with C programs must be saved in the "o" directory
  91. of your C program source.
  92.  
  93. Any routines you write with the BASIC assembler will be unknown to C.
  94. They have to be prototyped so that your C compiler recognises them and
  95. doesn't give an error when you use them.
  96.  
  97. An example:
  98. int foo(char k);
  99.  
  100. defines the foo() function as taking a character in R0 and returning an
  101. integer in R0.
  102.  
  103. You can then call the function from your C program, like so:
  104.   int a;
  105.   a = foo('f');
  106.  
  107. Assembler routines must obey the APCS if they are to be successfully
  108. interworked with C.
  109.  
  110. When you compile your program, it won't be linked to your assembler AOF
  111. files, so you have to tell the compiler to do this explicitly.
  112.  
  113. If you're using EasyC, you can drag AOF files onto the Object part of the
  114. EasyC window, and then compile + link in the normal way.
  115.  
  116. If you're using Acorn's C, you have to either use make files or an Obey file,
  117. or add the AOF filenames to the list of libraries in !CC.
  118.  
  119. An example of using Obey files:
  120.   *CC c.program -IC: -throwback -LC:o.stubs,o.eg -Desktop ^ -o output
  121.  
  122. will compile "c.program" and link it to the AOF file "o.eg"
  123.  
  124. See the Example directory for an example of this.
  125.  
  126.  
  127. History
  128. -------
  129. 0.01    First working version. No support for importing.
  130. 0.02    String table is now zero-padded to stop DecAOF thinking there is an
  131.           extra symbol at the end of the string table.
  132. 0.03    Support for importing PC-relative labels added
  133. 0.04    Support for importing Additive labels added.
  134. 0.05    Bug in memory allocation fixed.
  135.  
  136.  
  137. Licence
  138. -------
  139. AOFLib is freeware, and remains (c) Dizzy Wizard Software at all times.
  140.  
  141. You may freely distribute this archive provided it is unaltered, and no
  142. charge is made for it.
  143.  
  144. If you wish to put it on a disc in a PD library and you charge no more than
  145. £2 per disc (inc. postage & packing) then feel free to do so.
  146.  
  147.  
  148. Technical
  149. ---------
  150. AOFLib creates AOF files of version 150 with type 1 relocations.
  151.  
  152. It creates read/write code areas.
  153. If you want the source code for AOFLib, feel free to Email me at the address
  154. below and I will send it to you.
  155.  
  156. In the future this library may be re-written as a module and include support
  157. for multiple areas.
  158.  
  159.  
  160. Credits
  161. -------
  162. AOFLib was created with Edit, and AOF files were debugged using Zap 1.30.
  163.  
  164. Thanks to James Larcombe for spotting the problem with DecAOF.
  165.  
  166. Greetings to: James Larcombe, John Wright, Frederic Elisei, Ben Ingram,
  167.               Dave Williams, Alain Brobecker et al.
  168.  
  169.  
  170. Contacting Dizzy Wizard Software
  171. --------------------------------
  172. My Email address is W.P.Gibbons@damtp.cam.ac.uk
  173. My real address is:
  174.  
  175.   William Gibbons
  176.   52 Hurst Park Avenue
  177.   Cambridge
  178.   England
  179.   CB4 2AE
  180.  
  181.  
  182. The Dizzy Wizard Software Email address is dizzywiz@digibank.demon.co.uk 
  183.  
  184. Email us for a complete catalogue of our software, or mail us as user
  185. "Dizzy Wizard Software" on Digital DataBank BBS (tel. 01707 323531)
  186.  
  187.